library(ggplot2)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.0 ──
## ✓ tibble  3.1.0     ✓ purrr   0.3.4
## ✓ tidyr   1.1.3     ✓ stringr 1.4.0
## ✓ readr   1.4.0     ✓ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(arsenal)
library(data.table)
## 
## Attaching package: 'data.table'
## The following object is masked from 'package:purrr':
## 
##     transpose
## The following objects are masked from 'package:dplyr':
## 
##     between, first, last
library(expss)
## 
## Use 'expss_output_viewer()' to display tables in the RStudio Viewer.
##  To return to the console output, use 'expss_output_default()'.
## 
## Attaching package: 'expss'
## The following objects are masked from 'package:data.table':
## 
##     copy, like
## The following objects are masked from 'package:stringr':
## 
##     fixed, regex
## The following objects are masked from 'package:purrr':
## 
##     keep, modify, modify_if, transpose, when
## The following objects are masked from 'package:tidyr':
## 
##     contains, nest
## The following objects are masked from 'package:dplyr':
## 
##     between, compute, contains, first, last, na_if, recode, vars
## The following object is masked from 'package:ggplot2':
## 
##     vars
sleephygiene <- read_csv("/Users/Ivanics/Desktop/SPH/4th term/HealthComm/Qualtrics post/Sleep Hygiene Post-Survey_May 6, 2021_13.37.csv")
## 
## ── Column specification ────────────────────────────────────────────────────────
## cols(
##   .default = col_character()
## )
## ℹ Use `spec()` for the full column specifications.
sleephygiene$StartDate <- lubridate::ymd_hms(sleephygiene$StartDate)
## Warning: 2 failed to parse.
#Filter to include only responses beyond this time
sleephygiene <- sleephygiene %>% filter(StartDate >= "2021-04-29 00:00:00")

#Select out the variables we need
sleephygiene <- sleephygiene %>% select(Progress, `Duration (in seconds)`, Finished, LocationLatitude, LocationLongitude, DistributionChannel, UserLanguage, Q1, Q2, Q3, Q2_5_TEXT, Q4, Q5, Q6, Q37, Q92, Q93, Q94,  Q38, Q39, Q10_2, Q10_3, Q9, Q61, Q84, Q85, Q81, Q63, Q96_1, Q96_2, Q96_3, Q96_4, Q96_5, Q96_6, Q96_7, Q96_8, Q95, Q83, Q82, Q69, Q62, Q64, Q90, Q91, Q89_1, Q67_1, Q67_2, Q67_3, Q75_1, Q75_2, Q75_3, Q68, Q70, Q70_18_TEXT, Q87, Q71, Q72, Q79, Q79_5_TEXT, Q74, Q73, Q73_5_TEXT, Q59_1, Q59_2, Q59_3, Q59_4, Q44_1, Q44_2, Q44_3, Q44_4, Q44_5, Q44_6, Q44_7, Q44_8, Q44_9, Q52)

sleephygiene <- rowid_to_column(sleephygiene, "ID")
#General factor recoding
sleephygiene <- sleephygiene %>% mutate(
  Q1_consent = factor(Q1)) %>%
  mutate(Q2_program = factor(Q2)) %>%
  mutate(Q3_role = factor(Q3)) %>%
  mutate(Q4_gender = factor(Q4)) %>%
  mutate(Q5_age = factor(Q5)) %>%
  mutate(Q6_numberinhousehold = as.numeric(Q6)) %>%
  mutate(Q37_employed = factor(Q37)) %>%
  mutate(Q92_notSPHemployed = factor(Q92)) %>%
  mutate(Q93_worksetting = factor(Q93)) %>%
  mutate(Q94_dayornight = factor(Q94)) %>%
  mutate(Q38_worksetting = factor(Q38)) %>%
  mutate(Q39_dayornight = factor(Q39)) %>%
  mutate(Q10_hoursofsleeplast5workdays = as.numeric(Q10_2)) %>%
  mutate(Q10_hoursofsleeppastweekend = as.numeric(Q10_3)) %>%
  mutate(Q9_howoftensleepypastmonth = factor(Q9)) %>%
  mutate(Q61_howoftensleepypasttwoweeks = factor(Q61)) %>%
  mutate(Q84_awareofhowtoimprovesleepquality = factor(Q84)) %>%
  mutate(Q81_seenorheardfromGNbloombergcampaign = factor(Q81)) %>%
  mutate(Q63_recalltoolsfreetect = factor(Q63)) %>%
  mutate(Q96_picture1 = factor(Q96_1)) %>%
  mutate(Q96_picture2 = factor(Q96_2)) %>%
  mutate(Q96_picture3 = factor(Q96_3)) %>%
  mutate(Q96_picture4 = factor(Q96_4)) %>%
  mutate(Q96_picture5 = factor(Q96_5)) %>%
  mutate(Q96_picture6 = factor(Q96_6)) %>%
  mutate(Q96_picture7 = factor(Q96_7)) %>%
  mutate(Q96_picture8 = factor(Q96_8)) %>%
  mutate(Q95_talkedtoanyone = factor(Q95)) %>%
  mutate(Q82_knowanyonewhoengaged = factor(Q82)) %>%
  mutate(Q69_didyouengagewiththecampaign = factor(Q69)) %>%
  mutate(Q90_areyouhappywithyoursleepquality_awareofcampaign = factor(Q90)) %>%
  mutate(Q91_areyouhappywithyoursleepquality_notawareofcampaign = factor(Q91)) %>%
  mutate(Q89_ratesleepquality_notawareofcampaign = factor(Q89_1)) %>%
  mutate(Q67_move30minutes = as.numeric(Q67_1)) %>%
  mutate(Q67_breathing = as.numeric(Q67_2)) %>%
  mutate(Q67_powerdown = as.numeric(Q67_2)) %>%
  mutate(Q75_moving = factor(Q75_1)) %>%
  mutate(Q75_breathing = factor(Q75_2)) %>%
  mutate(Q75_powerdown = factor(Q75_3)) %>%
  mutate(Q68_timing = factor(Q68)) %>%
  mutate(Q87_idealtime = factor(Q87)) %>%
  mutate(Q74_rafflemotivating = factor(Q74)) %>%
  mutate(Q75_moving = factor(Q75_1)) %>%
  mutate(Q59_canmaintainhealthysleephabits = factor(Q59_1)) %>%
  mutate(Q59_cancutoutscreen = factor(Q59_2)) %>%
  mutate(Q59_canexercise = factor(Q59_3)) %>%
  mutate(Q59_canparticipateinbreathing = factor(Q59_4)) %>%
  mutate(Q44_goodnightsleepisimportant = factor(Q44_1)) %>%
  mutate(Q44_mentalclarity = factor(Q44_2)) %>%
  mutate(Q44_feelpositive = factor(Q44_3)) %>%
  mutate(Q44_cuttingoutscreenleadstobettersleep = factor(Q44_4)) %>%
  mutate(Q44_exercisingleadstobettersleep = factor(Q44_5)) %>%
  mutate(Q44_breathingexercisesleadstobettersleep = factor(Q44_6)) %>%
  mutate(Q44_iwillstopscreens = factor(Q44_7)) %>%
  mutate(Q44_iwillexercise = factor(Q44_8)) %>%
  mutate(Q44_iwillbreathe = factor(Q44_9)) %>%
  mutate(Q52_additionalcomments = factor(Q52))
#Q85
resp.split_85 <- strsplit(sleephygiene$Q85, ",")
lev <- unique(unlist(resp.split_85))
sleephygiene<- with(sleephygiene, data.frame(sleephygiene, t(sapply(resp.split_85, function(x) table(factor(x, levels=lev))))))

sleephygiene <- sleephygiene %>%
    mutate(Q85_waystoimprovesleepquality = case_when(
    Not.drinking.caffeinated.beverages.late.in.the.day == 1 ~ "Not drinking caffeinated beverages late in the day",
    Switching.off.electronics.one.hour.before.sleep == 1 ~ "Switching off electronics one hour before sleep",
    Incorporating.moderate.exercise.as.part.of.your.day == 1 ~ "Incorporating moderate exercise as part of your day",
    Increase.natural.bright.light.exposure.in.the.day == 1 ~ "Increase natural bright light exposure in the day",
    Reduce.irregular.or.long.daytime.naps == 1 ~ "Reduce irregular or long daytime naps",
    Try.to.sleep.and.wake.at.consistent.times == 1 ~ "Try to sleep and wake at consistent times",
    Take.a.melatonin.supplement == 1 ~ "Take a melatonin supplement",
    Decrease.alcohol.consumption == 1 ~ "Decrease alcohol consumption",
    Deep.breathing.exercises == 1 ~ "Deep breathing exercises"))

#Q83
resp.split_83 <- strsplit(sleephygiene$Q83, ",")
lev <- unique(unlist(resp.split_83))
sleephygiene<- with(sleephygiene, data.frame(sleephygiene, t(sapply(resp.split_83, function(x) table(factor(x, levels=lev))))))

sleephygiene <- sleephygiene %>%
    mutate(Q83_talkedtowho = case_when(
    Friends == 1 ~ "Friends",
    Spouse == 1 ~ "Spouse",
    Relatives == 1 ~ "Relatives",
    Colleague == 1 ~ "Colleague"))

#Q62
resp.split_62 <- strsplit(sleephygiene$Q62, ",")
lev <- unique(unlist(resp.split_62))
sleephygiene<- with(sleephygiene, data.frame(sleephygiene, t(sapply(resp.split_62, function(x) table(factor(x, levels=lev))))))

sleephygiene <- sleephygiene %>%
    mutate(Q62_howdidyouengage = case_when(
    Instagram.campaign == 1 ~ "Instagram campaign",
    Text.message.campaign == 1 ~ "Text message campaign",
    Word.of.mouth.discussion.with.others == 1 ~ "Word of mouth/discussion with others"))

#64
resp.split_64 <- strsplit(sleephygiene$Q64, ",")
lev <- unique(unlist(resp.split_64))
sleephygiene<- with(sleephygiene, data.frame(sleephygiene, t(sapply(resp.split_64, function(x) table(factor(x, levels=lev))))))

sleephygiene <- sleephygiene %>%
    mutate(Q64_whichtechniquedidyoutry = case_when(
    X.MoveMore == 1 ~ "Movemore",
    X.Breathe== 1 ~ "Breathe",
    X.PowerDown == 1 ~ "Powerdown",
    None.of.the.above == 1 ~ "None of the above"))

#70
resp.split_70 <- strsplit(sleephygiene$Q70, ",")
lev <- unique(unlist(resp.split_70))
sleephygiene<- with(sleephygiene, data.frame(sleephygiene, t(sapply(resp.split_70, function(x) table(factor(x, levels=lev))))))

sleephygiene <- sleephygiene %>%
    mutate(Q70_timingoftextsinconvenient = case_when(
    #Messages.were.too.frequent == 1 ~ "Messages were too frequent",
    Messages.were.too.infrequent== 1 ~ "Messages were too infrequent",
    Received.message.too.early.in.the.day == 1 ~ "Received message too early in the day",
    #Received.message.too.late.in.the.day == 1 ~ "Received message too late in the day",
    Other..please.explain.below. == 1 ~ "Other (please explain below)"))

#71
resp.split_71 <- strsplit(sleephygiene$Q71, ",")
lev <- unique(unlist(resp.split_71))
sleephygiene<- with(sleephygiene, data.frame(sleephygiene, t(sapply(resp.split_71, function(x) table(factor(x, levels=lev))))))

sleephygiene <- sleephygiene %>%
    mutate(Q71_whichchannelmosteducational = case_when(
    Text == 1 ~ "Text",
    Instagram == 1 ~ "Instagram"))
    #Discussion.with.others.about.the.campaign == 1 ~ "Discussion with others about the campaign",
    #None.of.the.above.1 == 1 ~ "None of the above"))

#72 - look into


#Q79
resp.split_79 <- strsplit(sleephygiene$Q79, ",")
lev <- unique(unlist(resp.split_79))
sleephygiene<- with(sleephygiene, data.frame(sleephygiene, t(sapply(resp.split_79, function(x) table(factor(x, levels=lev))))))

sleephygiene <- sleephygiene %>%
    mutate(Q79_moresuccessfuloutcomsuggestions = case_when(
    There.was.an.in.person.on.campus.component.to.the.campaign == 1 ~ "There was an in-person/on-campus component to the campaign",
    The.campaign.was.longer == 1 ~ "The campaign was longer",
    I.had.more.flexibility.in.my.day == 1 ~ "I had more flexibility in my day",
    There.were.subject.matter.experts.checking.in.with.me.one.on.one == 1 ~ "There were subject matter experts checking in with me one-on-one"))
    #Other == 1 ~ "Reduce irregular or long daytime naps",

#Q73
resp.split_73 <- strsplit(sleephygiene$Q73, ",")
lev <- unique(unlist(resp.split_73))
sleephygiene<- with(sleephygiene, data.frame(sleephygiene, t(sapply(resp.split_73, function(x) table(factor(x, levels=lev))))))

sleephygiene <- sleephygiene %>%
    mutate(Q73_hearabouthow = case_when(
    Instagram.1 == 1 ~ "Instagram",
    JHSPH.Activities.email == 1 ~ "JHSPH Activities email",
    #Class.announcement == 1 ~ "Class announcement",
    Word.of.mouth.discussion.with.others.1 == 1 ~ "Word of mouth/discussion with others"))
    #Other == 1 ~ "Reduce irregular or long daytime naps",

Plots for wakeup and sleep times

library(plotly)
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
workdayssleep <- sleephygiene %>% ggplot( aes(x=Q10_hoursofsleeplast5workdays)) +
    geom_histogram( binwidth=1, fill="#69b3a2", color="#e9ecef", alpha=0.9) +
    ggtitle("Hours of sleep last five workdays") +
    theme(
      plot.title = element_text(size=32)
    ) +
  labs(x="Number of hours of sleep in the past five workdays", y="Number of participants")
ggplotly(workdayssleep)
## Warning: Removed 4 rows containing non-finite values (stat_bin).
#Plot for weekend
weekend <- sleephygiene %>% ggplot( aes(x=Q10_hoursofsleeppastweekend)) +
    geom_histogram( binwidth=1, fill="#69b3a2", color="#e9ecef", alpha=0.9) +
    ggtitle("Hours of sleep last weekend") +
    theme(
      plot.title = element_text(size=32)
    ) +
  labs(x="Number of hours of sleep in the past weekend", y="Number of participants")
ggplotly(weekend)
## Warning: Removed 4 rows containing non-finite values (stat_bin).
#Tab 1
sleephygiene$Q9_howoftensleepypastmonth <- factor(sleephygiene$Q9_howoftensleepypastmonth, levels = c("Never", "Rarely", "Sometimes", "Very often", "Always"))
sleephygiene$Q61_howoftensleepypasttwoweeks <- factor(sleephygiene$Q61_howoftensleepypasttwoweeks, levels = c("Never", "Rarely", "Sometimes", "Very often", "Always"))
sleephygiene$Q89_ratesleepquality_notawareofcampaign <- factor(sleephygiene$Q89_ratesleepquality_notawareofcampaign, levels = c("Poor", "Fair", "Good", "Excellent"))
sleephygiene$Q75_moving <- factor(sleephygiene$Q75_moving, levels = c("Extremely unhelpful", "Somewhat unhelpful", "Neither helpful nor unhelpful", "Somewhat helpful", "Extremely helpful"))
sleephygiene$Q75_breathing <- factor(sleephygiene$Q75_breathing, levels = c("Extremely unhelpful", "Somewhat unhelpful", "Neither helpful nor unhelpful", "Somewhat helpful", "Extremely helpful"))
sleephygiene$Q75_powerdown <- factor(sleephygiene$Q75_powerdown, levels = c("Extremely unhelpful", "Somewhat unhelpful", "Neither helpful nor unhelpful", "Somewhat helpful", "Extremely helpful"))
sleephygiene$Q87_idealtime <- factor(sleephygiene$Q87_idealtime, levels = c("Early morning (6:00 am - 9:00 am)", "Late morning (9:01 am - 12:00 pm)", "Early afternoon (12:01 pm - 3:00 pm)", "Late afternoon (3:01 pm - 6:00 pm)", "Early evening (6:01 pm - 9:00 pm)", "Late evening (9:01 pm - 12:00 am)", "Other (please specify)"))
sleephygiene$Q59_canmaintainhealthysleephabits <- factor(sleephygiene$Q59_canmaintainhealthysleephabits, levels = c("Not at all confident", "Somewhat confident", "Extremely confident"))
sleephygiene$Q59_cancutoutscreen <- factor(sleephygiene$Q59_cancutoutscreen, levels = c("Not at all confident", "Somewhat confident", "Extremely confident"))
sleephygiene$Q59_canexercise <- factor(sleephygiene$Q59_canexercise, levels = c("Not at all confident", "Somewhat confident", "Extremely confident"))
sleephygiene$Q59_canparticipateinbreathing <- factor(sleephygiene$Q59_canparticipateinbreathing, levels = c("Not at all confident", "Somewhat confident", "Extremely confident"))
sleephygiene$Q44_goodnightsleepisimportant <- factor(sleephygiene$Q44_goodnightsleepisimportant, levels = c("Strongly disagree", "Somewhat disagree", "Neither agree nor disagree", "Somewhat agree", "Strongly agree"))
sleephygiene$Q44_mentalclarity <- factor(sleephygiene$Q44_mentalclarity, levels = c("Strongly disagree", "Somewhat disagree", "Neither agree nor disagree", "Somewhat agree", "Strongly agree"))
sleephygiene$Q44_feelpositive <- factor(sleephygiene$Q44_feelpositive, levels = c("Strongly disagree", "Somewhat disagree", "Neither agree nor disagree", "Somewhat agree", "Strongly agree"))
sleephygiene$Q44_cuttingoutscreenleadstobettersleep <- factor(sleephygiene$Q44_cuttingoutscreenleadstobettersleep, levels = c("Strongly disagree", "Somewhat disagree", "Neither agree nor disagree", "Somewhat agree", "Strongly agree"))
sleephygiene$Q44_exercisingleadstobettersleep <- factor(sleephygiene$Q44_exercisingleadstobettersleep, levels = c("Strongly disagree", "Somewhat disagree", "Neither agree nor disagree", "Somewhat agree", "Strongly agree"))
sleephygiene$Q44_breathingexercisesleadstobettersleep <- factor(sleephygiene$Q44_breathingexercisesleadstobettersleep, levels = c("Strongly disagree", "Somewhat disagree", "Neither agree nor disagree", "Somewhat agree", "Strongly agree"))
sleephygiene$Q44_iwillstopscreens <- factor(sleephygiene$Q44_iwillstopscreens, levels = c("Strongly disagree", "Somewhat disagree", "Neither agree nor disagree", "Somewhat agree", "Strongly agree"))
sleephygiene$Q44_iwillexercise <- factor(sleephygiene$Q44_iwillexercise, levels = c("Strongly disagree", "Somewhat disagree", "Neither agree nor disagree", "Somewhat agree", "Strongly agree"))
sleephygiene$Q44_iwillbreathe <- factor(sleephygiene$Q44_iwillbreathe, levels = c("Strongly disagree", "Somewhat disagree", "Neither agree nor disagree", "Somewhat agree", "Strongly agree"))

library(expss)
sleephygiene = apply_labels(sleephygiene,
                      Q3_role = "What is your role at Bloomberg",
                      Q4_gender = "Which best describes your gender identity?",
                      Q2_program = "What is your current program at Bloomberg?",
                      Q5_age = "How old are you?",
                      Q6_numberinhousehold = "How many people live in your household, including yourself?",
                      Q37_employed = "If you are a student at Bloomberg, are you currently employed outside of your education program?",
                      Q92_notSPHemployed = "Are you currently employed?",
                      Q93_worksetting = "Which of the following best describes your current work setting?",
                      Q94_dayornight = "Do you work day or night shifts?",
                      Q38_worksetting = "Which of the following best describes your current work setting?",
                      Q39_dayornight = "Do you work day or night shifts?",
                      Q10_hoursofsleeplast5workdays = "On average, how many hours of sleep did you get per night during the following periods of time: during the last 5 workdays?",
                      Q10_hoursofsleeppastweekend = "On average, how many hours of sleep did you get per night during the following periods of time: during the past weekend?",
                      Q9_howoftensleepypastmonth = "How often did you feel sleepy during the day in the past month?",
                      Q61_howoftensleepypasttwoweeks = "How often did you feel sleepy during the day during the past 2 weeks?",
                      Q84_awareofhowtoimprovesleepquality = "Do you know any ways a person can improve their sleep quality?",
                      Q85_waystoimprovesleepquality = "What are some of the ways to improve sleep quality that you know?",
                      Q81_seenorheardfromGNbloombergcampaign = "In the last two-three weeks have you heard, seen, or received any information from the #GoodnightBloomberg campaign led by JHSPH students promoting better sleep?",
                      Q63_recalltoolsfreetect = "Can you recall any specific tools, techniques, or resources from the campaign? Please describe below.",
                      Q96_picture1 = "Were these materials were utilized in our #GoodnightBloomberg campaign? Picture 1",
                      Q96_picture2 = "Were these materials were utilized in our #GoodnightBloomberg campaign? Picture 2",
                      Q96_picture3 = "Were these materials were utilized in our #GoodnightBloomberg campaign? Picture 3",
                      Q96_picture4 = "Were these materials were utilized in our #GoodnightBloomberg campaign? Picture 4",
                      Q96_picture5 = "Were these materials were utilized in our #GoodnightBloomberg campaign? Picture 5",
                      Q96_picture6 = "Were these materials were utilized in our #GoodnightBloomberg campaign? Picture 6",
                      Q96_picture7 = "Were these materials were utilized in our #GoodnightBloomberg campaign? Picture 7",
                      Q96_picture8 = "Were these materials were utilized in our #GoodnightBloomberg campaign? Picture 8",
                      Q95_talkedtoanyone = "Have you talked to anyone about the #GoodnightBloomberg campaign?",
                      Q83_talkedtowho = "Please indicate with whom you talked about #GoodnightBloomberg (check all that apply).",
                      Q82_knowanyonewhoengaged = "Do you know anyone who engaged in any way with the #GoodnightBloomberg campaign about promoting better sleep?",
                      Q69_didyouengagewiththecampaign = "Did you engage in any way with the #GoodnightBloomberg campaign led by JHSPH students during the past 2 weeks?",
                      Q62_howdidyouengage = "Please select which of the following parts of the #GoodnightBloomberg campaign you engaged in:",
                      Q64_whichtechniquedidyoutry = "Which of the following techniques did you try at least once in the last 2 weeks (choose all that apply)?", 
                      Q90_areyouhappywithyoursleepquality_awareofcampaign = "Are you happy with your sleep quality overall currently?", 
                      Q91_areyouhappywithyoursleepquality_notawareofcampaign = "Are you happy with your sleep quality overall currently?", 
                      Q89_ratesleepquality_notawareofcampaign = "Please rate your sleep quality from the following options: In the last two weeks? (on average)",
                      Q67_move30minutes =  "In the last two weeks, how many days did you participate in the following techniques? Move 30 minutes total per day",
                      Q67_breathing = "In the last two weeks, how many days did you participate in the following techniques? Use a breathing exercise",
                      Q67_powerdown = "In the last two weeks, how many days did you participate in the following techniques? Power down your screens (i.e. cell phone, tablet, computer, TV) 1 hour before bed",
                      Q75_moving = "How helpful did you find the following activities for getting better quality sleep in the past 2 weeks? Moving 30 minutes total per day",
                      Q75_breathing = "How helpful did you find the following activities for getting better quality sleep in the past 2 weeks? Using a breathing exercise",
                      Q75_powerdown = "How helpful did you find the following activities for getting better quality sleep in the past 2 weeks? Powering down your screens (i.e. cell phone, tablet, computer, TV) 1 hour before bed",
                      Q68_timing = "Was the timing of the texts/posts convenient for you to adopt the recommended activity? ",
                      Q70_timingoftextsinconvenient = "Please provide information below about why the timing of the texts/posts was inconvenient?", 
                      Q87_idealtime = "What would have been the ideal time to receive the message (EST/EDT)?",
                      Q71_whichchannelmosteducational = "Which channel did you find the most educational?",
                      Q79_moresuccessfuloutcomsuggestions = "I think I would have had a more successful outcome (e.g. better sleep quality) if (choose all that may apply):",
                      Q74_rafflemotivating = "Did you find the raffles motivating for participation in the #GoodnightBloomberg campaign?",
                      Q73_hearabouthow = "How did you hear about the #GoodnightBloomberg campaign?",
                      Q59_canmaintainhealthysleephabits = "Please tell us how confident you feel practicing the following behaviors in order to get better sleep: I can maintain healthy sleep habits.",
                      Q59_cancutoutscreen = "Please tell us how confident you feel practicing the following behaviors in order to get better sleep: I can cut out screen use 1 hour before bed.",
                      Q59_canexercise = "Please tell us how confident you feel practicing the following behaviors in order to get better sleep: I can exercise for 30 minutes total each day.", 
                      Q59_canparticipateinbreathing = "Please tell us how confident you feel practicing the following behaviors in order to get better sleep: I can participate in a breathing exercise during the day or before bed.", 
                      Q44_goodnightsleepisimportant = "Please rate your agreement with the following statements: Getting a good night's sleep is important to me.",
                      Q44_mentalclarity = "Please rate your agreement with the following statements: Having a regular sleep routine improves mental clarity/sharpness.",
                      Q44_feelpositive = "Please rate your agreement with the following statements: I feel positive about the quality of my sleep.",
                      Q44_cuttingoutscreenleadstobettersleep = "Please rate your agreement with the following statements: I think cutting out screen use 1 hour before bed leads to better sleep.",
                      Q44_exercisingleadstobettersleep = "Please rate your agreement with the following statements: I think exercising regularly leads to better sleep.",
                      Q44_breathingexercisesleadstobettersleep = "Please rate your agreement with the following statements: I think participating in breathing exercises during the day or before bed leads to better sleep.",
                      Q44_iwillstopscreens = "Please rate your agreement with the following statements: In the next two weeks, I will stop using screens 1 hour before bed for better sleep.",
                      Q44_iwillexercise = "Please rate your agreement with the following statements: In the next two weeks, I will exercise for at least 30 minutes total each day for better sleep.",
                      Q44_iwillbreathe = "Please rate your agreement with the following statements: In the next two weeks, I will do a daily breathing exercise for better sleep.",
                      Q52_additionalcomments = "Please share any additional comments or feedback you have about the #GoodnightBloomberg sleep campaign below."
                      )
attach(sleephygiene)
tab1 <- tableby(~ Q3_role + 
                  Q4_gender +
                  Q5_age +
                  Q6_numberinhousehold +
                  Q37_employed +
                  Q10_hoursofsleeplast5workdays +
                  Q10_hoursofsleeppastweekend +
                  Q9_howoftensleepypastmonth +
                  Q61_howoftensleepypasttwoweeks +
                  Q84_awareofhowtoimprovesleepquality +
                  Q81_seenorheardfromGNbloombergcampaign +
                  #Q63_recalltoolsfreetect +
                  Q96_picture1 +
                  Q96_picture2 +
                  Q96_picture3 +
                  Q96_picture4 +
                  Q96_picture5 +
                  Q96_picture6 +
                  Q96_picture7 +
                  Q96_picture8 +
                  Q95_talkedtoanyone +
                  Q82_knowanyonewhoengaged +
                  Q69_didyouengagewiththecampaign +
                  Q67_move30minutes +
                  Q67_breathing +
                  Q67_powerdown +
                  Q68_timing + 
                  Q79_moresuccessfuloutcomsuggestions +
                  Q59_canmaintainhealthysleephabits +
                  Q59_cancutoutscreen +
                  Q59_canexercise +
                  Q59_canparticipateinbreathing +
                  Q44_goodnightsleepisimportant +
                  Q44_mentalclarity +
                  Q44_feelpositive +
                  Q44_cuttingoutscreenleadstobettersleep +
                  Q44_exercisingleadstobettersleep +
                  Q44_breathingexercisesleadstobettersleep +
                  Q44_iwillstopscreens +
                  Q44_iwillexercise +
                  Q44_iwillbreathe,
                data=sleephygiene, test=TRUE, total=TRUE, 
                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
summary(tab1, title='Table 1. Baseline information', pfootnote=TRUE, digits = 2)
Table 1. Baseline information
Overall (N=149)
What is your role at Bloomberg
   N-Miss 4
   Faculty/Staff Member 9 (6.2%)
   Full-time student 82 (56.6%)
   Not affiliated with Bloomberg School of Public Health 1 (0.7%)
   Part-time student 53 (36.6%)
Which best describes your gender identity?
   N-Miss 4
   Female 121 (83.4%)
   Male 23 (15.9%)
   Non-binary / third gender 1 (0.7%)
How old are you?
   N-Miss 4
   18-25 44 (30.3%)
   26-34 63 (43.4%)
   35-44 24 (16.6%)
   45-54 12 (8.3%)
   55-64 1 (0.7%)
   64-75 1 (0.7%)
How many people live in your household, including yourself?
   Median (Q1, Q3) 2.00 (2.00, 3.00)
If you are a student at Bloomberg, are you currently employed outside of your education program?
   N-Miss 4
   N/A - I am not a student at Bloomberg 9 (6.2%)
   No 66 (45.5%)
   Yes 70 (48.3%)
On average, how many hours of sleep did you get per night during the following periods of time: during the last 5 workdays?
   Median (Q1, Q3) 7.00 (6.00, 7.00)
On average, how many hours of sleep did you get per night during the following periods of time: during the past weekend?
   Median (Q1, Q3) 8.00 (7.00, 8.00)
How often did you feel sleepy during the day in the past month?
   N-Miss 56
   Never 3 (3.2%)
   Rarely 14 (15.1%)
   Sometimes 66 (71.0%)
   Very often 0 (0.0%)
   Always 10 (10.8%)
How often did you feel sleepy during the day during the past 2 weeks?
   N-Miss 54
   Never 2 (2.1%)
   Rarely 23 (24.2%)
   Sometimes 54 (56.8%)
   Very often 0 (0.0%)
   Always 16 (16.8%)
Do you know any ways a person can improve their sleep quality?
   N-Miss 5
   No 7 (4.9%)
   Yes 137 (95.1%)
In the last two-three weeks have you heard, seen, or received any information from the #GoodnightBloomberg campaign led by JHSPH students promoting better sleep?
   N-Miss 5
   Don’t know 33 (22.9%)
   No 57 (39.6%)
   Yes 54 (37.5%)
Were these materials were utilized in our #GoodnightBloomberg campaign? Picture 1
   N-Miss 22
   No 24 (18.9%)
   Not sure 97 (76.4%)
   Yes 6 (4.7%)
Were these materials were utilized in our #GoodnightBloomberg campaign? Picture 2
   N-Miss 17
   No 7 (5.3%)
   Not sure 76 (57.6%)
   Yes 49 (37.1%)
Were these materials were utilized in our #GoodnightBloomberg campaign? Picture 3
   N-Miss 21
   No 20 (15.6%)
   Not sure 101 (78.9%)
   Yes 7 (5.5%)
Were these materials were utilized in our #GoodnightBloomberg campaign? Picture 4
   N-Miss 22
   No 18 (14.2%)
   Not sure 98 (77.2%)
   Yes 11 (8.7%)
Were these materials were utilized in our #GoodnightBloomberg campaign? Picture 5
   N-Miss 20
   No 14 (10.9%)
   Not sure 97 (75.2%)
   Yes 18 (14.0%)
Were these materials were utilized in our #GoodnightBloomberg campaign? Picture 6
   N-Miss 20
   No 19 (14.7%)
   Not sure 106 (82.2%)
   Yes 4 (3.1%)
Were these materials were utilized in our #GoodnightBloomberg campaign? Picture 7
   N-Miss 20
   No 17 (13.2%)
   Not sure 100 (77.5%)
   Yes 12 (9.3%)
Were these materials were utilized in our #GoodnightBloomberg campaign? Picture 8
   N-Miss 21
   No 18 (14.1%)
   Not sure 104 (81.2%)
   Yes 6 (4.7%)
Have you talked to anyone about the #GoodnightBloomberg campaign?
   N-Miss 5
   No 131 (91.0%)
   Yes 13 (9.0%)
Do you know anyone who engaged in any way with the #GoodnightBloomberg campaign about promoting better sleep?
   N-Miss 5
   No 134 (93.1%)
   Yes 10 (6.9%)
Did you engage in any way with the #GoodnightBloomberg campaign led by JHSPH students during the past 2 weeks?
   N-Miss 5
   No 119 (82.6%)
   Yes 25 (17.4%)
In the last two weeks, how many days did you participate in the following techniques? Move 30 minutes total per day
   Median (Q1, Q3) 9.00 (5.00, 12.00)
In the last two weeks, how many days did you participate in the following techniques? Use a breathing exercise
   Median (Q1, Q3) 2.50 (1.00, 6.00)
In the last two weeks, how many days did you participate in the following techniques? Power down your screens (i.e. cell phone, tablet, computer, TV) 1 hour before bed
   Median (Q1, Q3) 2.50 (1.00, 6.00)
Was the timing of the texts/posts convenient for you to adopt the recommended activity?
   N-Miss 34
   No 54 (47.0%)
   Yes 61 (53.0%)
I think I would have had a more successful outcome (e.g. better sleep quality) if (choose all that may apply):
   N-Miss 47
   I had more flexibility in my day 42 (41.2%)
   The campaign was longer 24 (23.5%)
   There was an in-person/on-campus component to the campaign 25 (24.5%)
   There were subject matter experts checking in with me one-on-one 11 (10.8%)
Please tell us how confident you feel practicing the following behaviors in order to get better sleep: I can maintain healthy sleep habits.
   N-Miss 7
   Not at all confident 26 (18.3%)
   Somewhat confident 86 (60.6%)
   Extremely confident 30 (21.1%)
Please tell us how confident you feel practicing the following behaviors in order to get better sleep: I can cut out screen use 1 hour before bed.
   N-Miss 7
   Not at all confident 70 (49.3%)
   Somewhat confident 54 (38.0%)
   Extremely confident 18 (12.7%)
Please tell us how confident you feel practicing the following behaviors in order to get better sleep: I can exercise for 30 minutes total each day.
   N-Miss 7
   Not at all confident 18 (12.7%)
   Somewhat confident 61 (43.0%)
   Extremely confident 63 (44.4%)
Please tell us how confident you feel practicing the following behaviors in order to get better sleep: I can participate in a breathing exercise during the day or before bed.
   N-Miss 7
   Not at all confident 17 (12.0%)
   Somewhat confident 75 (52.8%)
   Extremely confident 50 (35.2%)
Please rate your agreement with the following statements: Getting a good night’s sleep is important to me.
   N-Miss 7
   Strongly disagree 0 (0.0%)
   Somewhat disagree 1 (0.7%)
   Neither agree nor disagree 1 (0.7%)
   Somewhat agree 25 (17.6%)
   Strongly agree 115 (81.0%)
Please rate your agreement with the following statements: Having a regular sleep routine improves mental clarity/sharpness.
   N-Miss 7
   Strongly disagree 0 (0.0%)
   Somewhat disagree 1 (0.7%)
   Neither agree nor disagree 0 (0.0%)
   Somewhat agree 23 (16.2%)
   Strongly agree 118 (83.1%)
Please rate your agreement with the following statements: I feel positive about the quality of my sleep.
   N-Miss 7
   Strongly disagree 11 (7.7%)
   Somewhat disagree 33 (23.2%)
   Neither agree nor disagree 23 (16.2%)
   Somewhat agree 52 (36.6%)
   Strongly agree 23 (16.2%)
Please rate your agreement with the following statements: I think cutting out screen use 1 hour before bed leads to better sleep.
   N-Miss 6
   Strongly disagree 1 (0.7%)
   Somewhat disagree 5 (3.5%)
   Neither agree nor disagree 19 (13.3%)
   Somewhat agree 50 (35.0%)
   Strongly agree 68 (47.6%)
Please rate your agreement with the following statements: I think exercising regularly leads to better sleep.
   N-Miss 6
   Strongly disagree 0 (0.0%)
   Somewhat disagree 2 (1.4%)
   Neither agree nor disagree 5 (3.5%)
   Somewhat agree 40 (28.0%)
   Strongly agree 96 (67.1%)
Please rate your agreement with the following statements: I think participating in breathing exercises during the day or before bed leads to better sleep.
   N-Miss 6
   Strongly disagree 0 (0.0%)
   Somewhat disagree 5 (3.5%)
   Neither agree nor disagree 36 (25.2%)
   Somewhat agree 57 (39.9%)
   Strongly agree 45 (31.5%)
Please rate your agreement with the following statements: In the next two weeks, I will stop using screens 1 hour before bed for better sleep.
   N-Miss 8
   Strongly disagree 27 (19.1%)
   Somewhat disagree 27 (19.1%)
   Neither agree nor disagree 28 (19.9%)
   Somewhat agree 41 (29.1%)
   Strongly agree 18 (12.8%)
Please rate your agreement with the following statements: In the next two weeks, I will exercise for at least 30 minutes total each day for better sleep.
   N-Miss 7
   Strongly disagree 3 (2.1%)
   Somewhat disagree 8 (5.6%)
   Neither agree nor disagree 17 (12.0%)
   Somewhat agree 49 (34.5%)
   Strongly agree 65 (45.8%)
Please rate your agreement with the following statements: In the next two weeks, I will do a daily breathing exercise for better sleep.
   N-Miss 7
   Strongly disagree 12 (8.5%)
   Somewhat disagree 21 (14.8%)
   Neither agree nor disagree 26 (18.3%)
   Somewhat agree 55 (38.7%)
   Strongly agree 28 (19.7%)
#If student
student <- sleephygiene %>% filter(Q3_role %in% c("Part-time student", "Full-time student"))

tab2 <- tableby(~ Q2_program,
                data=student, test=TRUE, total=TRUE, 
                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
summary(tab2, title='Table 1. Baseline information', pfootnote=TRUE, digits = 2)
Table 1. Baseline information
Overall (N=135)
What is your current program at Bloomberg?
   Doctoral Student 29 (21.5%)
   Masters Student 90 (66.7%)
   Other 6 (4.4%)
   Post-doctoral student 10 (7.4%)
#If employed 
nonbloombergstudentemployed <- sleephygiene %>% filter(Q37_employed == "N/A - I am not a student at Bloomberg")

tab3 <- tableby(~ Q92_notSPHemployed,
                data=nonbloombergstudentemployed, test=TRUE, total=TRUE, 
                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
summary(tab3, title='Table 1. Baseline information', pfootnote=TRUE, digits = 2)
Table 1. Baseline information
Overall (N=9)
Are you currently employed?
   Yes 9 (100.0%)
#If employed and not bloomberg
employed <- nonbloombergstudentemployed %>% filter(Q92_notSPHemployed == "Yes")

tab4 <- tableby(~ Q93_worksetting,
                data=employed, test=TRUE, total=TRUE, 
                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
summary(tab4, title='Table 1. Baseline information', pfootnote=TRUE, digits = 2)
Table 1. Baseline information
Overall (N=9)
Which of the following best describes your current work setting?
   I sometimes work at home and sometimes at another location 3 (33.3%)
   I work from home 5 (55.6%)
   I work in a location away from my home 1 (11.1%)
#wfh not bloomberg
#wfhnotbloomberg <- nonbloombergstudentemployed %>% filter(Q93_worksetting == "I work in a location away from my home")

#tab5 <- tableby(~ Q94_dayornight,
#                data=wfhnotbloomberg, test=TRUE, total=TRUE, 
#                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
#summary(tab5, title='Table 1. Baseline information', pfootnote=TRUE, digits = 2)

#student at bloomberg
studentemployed <- student %>% filter(Q37_employed == "Yes")

tab6 <- tableby(~ Q38_worksetting,
                data=studentemployed, test=TRUE, total=TRUE, 
                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
summary(tab6, title='Table 1. Baseline information', pfootnote=TRUE, digits = 2)
Table 1. Baseline information
Overall (N=70)
Which of the following best describes your current work setting?
   N-Miss 2
   I sometimes work at home and sometimes at another location 16 (23.5%)
   I work from home 40 (58.8%)
   I work in a location away from my home 12 (17.6%)
studentemployedlocation <- student %>% filter(Q39_dayornight == "I work in a location away from my home")

#tab7 <- tableby(~ Q39_dayornight,
#                data=studentemployedlocation, test=TRUE, total=TRUE, 
#                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
#summary(tab7, title='Table 1. Baseline information', pfootnote=TRUE, digits = 2)


#Aware of how to improve sleep quality
awareofsleepqualityimprovements <- sleephygiene %>% filter(Q84_awareofhowtoimprovesleepquality == "Yes")

tab8 <- tableby(~ Q85_waystoimprovesleepquality,
                data=awareofsleepqualityimprovements, test=TRUE, total=TRUE, 
                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
summary(tab8, title='Table 1. Baseline information', pfootnote=TRUE, digits = 2)
Table 1. Baseline information
Overall (N=137)
What are some of the ways to improve sleep quality that you know?
   N-Miss 1
   Not drinking caffeinated beverages late in the day 127 (93.4%)
   Reduce irregular or long daytime naps 1 (0.7%)
   Switching off electronics one hour before sleep 7 (5.1%)
   Try to sleep and wake at consistent times 1 (0.7%)
#Talked to someone
talkedtosomeone <- sleephygiene %>% filter(Q95_talkedtoanyone == "Yes")

tab9 <- tableby(~ Q83_talkedtowho,
                data=talkedtosomeone, test=TRUE, total=TRUE, 
                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
summary(tab9, title='Table 1. Baseline information', pfootnote=TRUE, digits = 2)
Table 1. Baseline information
Overall (N=13)
Please indicate with whom you talked about #GoodnightBloomberg (check all that apply).
   N-Miss 1
   Colleague 1 (8.3%)
   Friends 9 (75.0%)
   Spouse 2 (16.7%)
#engaged in any way
engagedwiththecampaign <- sleephygiene %>% filter(Q69_didyouengagewiththecampaign == "Yes")

tab10 <- tableby(~ Q62_howdidyouengage +
                   Q64_whichtechniquedidyoutry +
                   Q90_areyouhappywithyoursleepquality_awareofcampaign +
                   Q75_moving +
                   Q75_breathing +
                   Q75_powerdown,
                data=engagedwiththecampaign, test=TRUE, total=TRUE, 
                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
summary(tab10, title='Table 1. Baseline information', pfootnote=TRUE, digits = 2)
Table 1. Baseline information
Overall (N=25)
Please select which of the following parts of the #GoodnightBloomberg campaign you engaged in:
   N-Miss 1
   Instagram campaign 15 (62.5%)
   Text message campaign 8 (33.3%)
   Word of mouth/discussion with others 1 (4.2%)
Which of the following techniques did you try at least once in the last 2 weeks (choose all that apply)?
   Breathe 5 (20.0%)
   Movemore 15 (60.0%)
   None of the above 2 (8.0%)
   Powerdown 3 (12.0%)
Are you happy with your sleep quality overall currently?
   N-Miss 1
   No 10 (41.7%)
   Yes 14 (58.3%)
How helpful did you find the following activities for getting better quality sleep in the past 2 weeks? Moving 30 minutes total per day
   N-Miss 8
   Extremely unhelpful 0 (0.0%)
   Somewhat unhelpful 0 (0.0%)
   Neither helpful nor unhelpful 0 (0.0%)
   Somewhat helpful 13 (76.5%)
   Extremely helpful 4 (23.5%)
How helpful did you find the following activities for getting better quality sleep in the past 2 weeks? Using a breathing exercise
   N-Miss 12
   Extremely unhelpful 0 (0.0%)
   Somewhat unhelpful 0 (0.0%)
   Neither helpful nor unhelpful 7 (53.8%)
   Somewhat helpful 4 (30.8%)
   Extremely helpful 2 (15.4%)
How helpful did you find the following activities for getting better quality sleep in the past 2 weeks? Powering down your screens (i.e. cell phone, tablet, computer, TV) 1 hour before bed
   N-Miss 16
   Extremely unhelpful 0 (0.0%)
   Somewhat unhelpful 0 (0.0%)
   Neither helpful nor unhelpful 2 (22.2%)
   Somewhat helpful 5 (55.6%)
   Extremely helpful 2 (22.2%)
#did not engagee in any way
noengagementwiththecampagin <- sleephygiene %>% filter(Q69_didyouengagewiththecampaign %in% c("No", "Don't know"))

tab11 <- tableby(~ Q91_areyouhappywithyoursleepquality_notawareofcampaign +
                   Q89_ratesleepquality_notawareofcampaign,
                data=noengagementwiththecampagin, test=TRUE, total=TRUE, 
                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
summary(tab11, title='Table 1. Baseline information', pfootnote=TRUE, digits = 2)
Table 1. Baseline information
Overall (N=119)
Are you happy with your sleep quality overall currently?
   N-Miss 32
   No 52 (59.8%)
   Yes 35 (40.2%)
Please rate your sleep quality from the following options: In the last two weeks? (on average)
   N-Miss 30
   Poor 9 (10.1%)
   Fair 38 (42.7%)
   Good 37 (41.6%)
   Excellent 5 (5.6%)
#not convenient 
notconvenient <- sleephygiene %>% filter(Q68_timing == "No")

tab12 <- tableby(~ Q70_timingoftextsinconvenient,
                data=noengagementwiththecampagin, test=TRUE, total=TRUE, 
                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
summary(tab12, title='Table 1. Baseline information', pfootnote=TRUE, digits = 2)
Table 1. Baseline information
Overall (N=119)
Please provide information below about why the timing of the texts/posts was inconvenient?
   N-Miss 86
   Messages were too infrequent 5 (15.2%)
   Other (please explain below) 27 (81.8%)
   Received message too early in the day 1 (3.0%)
#tooearlyintheday
tooearlyortoolate <- notconvenient %>% filter(Q70_timingoftextsinconvenient %in% c("Received message too early in the day", "Received message too late in the day"))

tab13 <- tableby(~ Q87_idealtime,
                data=tooearlyortoolate, test=TRUE, total=TRUE, 
                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
summary(tab13, title='Table 1. Baseline information', pfootnote=TRUE, digits = 2)
Table 1. Baseline information
Overall (N=3)
What would have been the ideal time to receive the message (EST/EDT)?
   Early morning (6:00 am - 9:00 am) 0 (0.0%)
   Late morning (9:01 am - 12:00 pm) 1 (33.3%)
   Early afternoon (12:01 pm - 3:00 pm) 0 (0.0%)
   Late afternoon (3:01 pm - 6:00 pm) 0 (0.0%)
   Early evening (6:01 pm - 9:00 pm) 2 (66.7%)
   Late evening (9:01 pm - 12:00 am) 0 (0.0%)
   Other (please specify) 0 (0.0%)
#whichmosteducational
instagramortext <- engagedwiththecampaign %>% filter(Q62_howdidyouengage %in% c("Instagram", "Text message campaign"))

#tab14 <- tableby(~ Q71_whichchannelmosteducational +
#                   Q72,
#                data=instagramortext, test=TRUE, total=TRUE, 
#                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
#summary(tab14, title='Table 1. Baseline information', pfootnote=TRUE, digits = 2)

#instagram
instagram <- engagedwiththecampaign %>% filter(Q62_howdidyouengage == "Instagram campaign")

tab15 <- tableby(~ Q74_rafflemotivating,
                data=instagram, test=TRUE, total=TRUE, 
                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
summary(tab15, title='Table 1. Baseline information', pfootnote=TRUE, digits = 2)
Table 1. Baseline information
Overall (N=15)
Did you find the raffles motivating for participation in the #GoodnightBloomberg campaign?
   No 4 (26.7%)
   Yes 11 (73.3%)
#seenorheardofthecampiagn
seenordheard <- sleephygiene %>% filter(Q81_seenorheardfromGNbloombergcampaign == "Yes")

tab16 <- tableby(~ Q81_seenorheardfromGNbloombergcampaign,
                data=seenordheard, test=TRUE, total=TRUE, 
                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
summary(tab16, title='Table 1. Baseline information', pfootnote=TRUE, digits = 2)
Table 1. Baseline information
Overall (N=54)
In the last two-three weeks have you heard, seen, or received any information from the #GoodnightBloomberg campaign led by JHSPH students promoting better sleep?
   Don’t know 0 (0.0%)
   No 0 (0.0%)
   Yes 54 (100.0%)
sleephygiene <- sleephygiene %>% mutate(Engagementyesno = case_when(
  Q69_didyouengagewiththecampaign == "Yes" ~ 1,
  Q69_didyouengagewiththecampaign == "No" ~ 0,
  Q69_didyouengagewiththecampaign == "Don't know" ~ 0,
  is.na(Q69_didyouengagewiththecampaign) ~ NA_real_)) %>%
  mutate(Engagementyesno = factor(Engagementyesno))

tab1 <- tableby(Engagementyesno ~ Q3_role + 
                  Q4_gender +
                  Q5_age +
                  Q6_numberinhousehold +
                  Q37_employed +
                  Q10_hoursofsleeplast5workdays +
                  Q10_hoursofsleeppastweekend +
                  Q9_howoftensleepypastmonth +
                  Q61_howoftensleepypasttwoweeks +
                  Q84_awareofhowtoimprovesleepquality +
                  Q81_seenorheardfromGNbloombergcampaign +
                  Q96_picture1 +
                  Q96_picture2 +
                  Q96_picture3 +
                  Q96_picture4 +
                  Q96_picture5 +
                  Q96_picture6 +
                  Q96_picture7 +
                  Q96_picture8 +
                  Q95_talkedtoanyone +
                  Q82_knowanyonewhoengaged +
                  Q69_didyouengagewiththecampaign +
                  Q67_move30minutes +
                  Q67_breathing +
                  Q67_powerdown +
                  Q68_timing + 
                  Q79_moresuccessfuloutcomsuggestions +
                  Q59_canmaintainhealthysleephabits +
                  Q59_cancutoutscreen +
                  Q59_canexercise +
                  Q59_canparticipateinbreathing +
                  Q44_goodnightsleepisimportant +
                  Q44_mentalclarity +
                  Q44_feelpositive +
                  Q44_cuttingoutscreenleadstobettersleep +
                  Q44_exercisingleadstobettersleep +
                  Q44_breathingexercisesleadstobettersleep +
                  Q44_iwillstopscreens +
                  Q44_iwillexercise +
                  Q44_iwillbreathe,
                data=sleephygiene, test=TRUE, total=TRUE, 
                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
summary(tab1, title='Table 1. Baseline information', pfootnote=TRUE, digits = 2)
Table 1. Baseline information
0 (N=119) 1 (N=25) Total (N=144) p value
What is your role at Bloomberg
   N-Miss 0 2 2
   Faculty/Staff Member 9 (7.6%) 0 (0.0%) 9 (6.3%)
   Full-time student 65 (54.6%) 16 (69.6%) 81 (57.0%)
   Not affiliated with Bloomberg School of Public Health 0 (0.0%) 0 (0.0%) 0 (0.0%)
   Part-time student 45 (37.8%) 7 (30.4%) 52 (36.6%)
Which best describes your gender identity? 0.5501
   N-Miss 0 2 2
   Female 98 (82.4%) 21 (91.3%) 119 (83.8%)
   Male 20 (16.8%) 2 (8.7%) 22 (15.5%)
   Non-binary / third gender 1 (0.8%) 0 (0.0%) 1 (0.7%)
How old are you? 0.9951
   N-Miss 0 2 2
   18-25 37 (31.1%) 7 (30.4%) 44 (31.0%)
   26-34 51 (42.9%) 10 (43.5%) 61 (43.0%)
   35-44 19 (16.0%) 4 (17.4%) 23 (16.2%)
   45-54 10 (8.4%) 2 (8.7%) 12 (8.5%)
   55-64 1 (0.8%) 0 (0.0%) 1 (0.7%)
   64-75 1 (0.8%) 0 (0.0%) 1 (0.7%)
How many people live in your household, including yourself? 0.0112
   Median (Q1, Q3) 2.00 (1.00, 3.00) 3.00 (2.00, 4.00) 2.00 (2.00, 3.00)
If you are a student at Bloomberg, are you currently employed outside of your education program? 0.0241
   N-Miss 0 2 2
   N/A - I am not a student at Bloomberg 8 (6.7%) 0 (0.0%) 8 (5.6%)
   No 59 (49.6%) 6 (26.1%) 65 (45.8%)
   Yes 52 (43.7%) 17 (73.9%) 69 (48.6%)
On average, how many hours of sleep did you get per night during the following periods of time: during the last 5 workdays? 0.7522
   Median (Q1, Q3) 7.00 (6.00, 7.00) 7.00 (6.00, 8.00) 7.00 (6.00, 7.00)
On average, how many hours of sleep did you get per night during the following periods of time: during the past weekend? 0.1832
   Median (Q1, Q3) 8.00 (7.00, 8.00) 8.00 (7.00, 9.00) 8.00 (7.00, 8.00)
How often did you feel sleepy during the day in the past month?
   N-Miss 43 10 53
   Never 3 (3.9%) 0 (0.0%) 3 (3.3%)
   Rarely 10 (13.2%) 3 (20.0%) 13 (14.3%)
   Sometimes 56 (73.7%) 10 (66.7%) 66 (72.5%)
   Very often 0 (0.0%) 0 (0.0%) 0 (0.0%)
   Always 7 (9.2%) 2 (13.3%) 9 (9.9%)
How often did you feel sleepy during the day during the past 2 weeks?
   N-Miss 42 9 51
   Never 2 (2.6%) 0 (0.0%) 2 (2.2%)
   Rarely 17 (22.1%) 5 (31.2%) 22 (23.7%)
   Sometimes 45 (58.4%) 9 (56.2%) 54 (58.1%)
   Very often 0 (0.0%) 0 (0.0%) 0 (0.0%)
   Always 13 (16.9%) 2 (12.5%) 15 (16.1%)
Do you know any ways a person can improve their sleep quality? 0.2141
   No 7 (5.9%) 0 (0.0%) 7 (4.9%)
   Yes 112 (94.1%) 25 (100.0%) 137 (95.1%)
In the last two-three weeks have you heard, seen, or received any information from the #GoodnightBloomberg campaign led by JHSPH students promoting better sleep? < 0.0011
   Don’t know 32 (26.9%) 1 (4.0%) 33 (22.9%)
   No 57 (47.9%) 0 (0.0%) 57 (39.6%)
   Yes 30 (25.2%) 24 (96.0%) 54 (37.5%)
Were these materials were utilized in our #GoodnightBloomberg campaign? Picture 1 < 0.0011
   N-Miss 14 3 17
   No 13 (12.4%) 11 (50.0%) 24 (18.9%)
   Not sure 88 (83.8%) 9 (40.9%) 97 (76.4%)
   Yes 4 (3.8%) 2 (9.1%) 6 (4.7%)
Were these materials were utilized in our #GoodnightBloomberg campaign? Picture 2 < 0.0011
   N-Miss 11 1 12
   No 7 (6.5%) 0 (0.0%) 7 (5.3%)
   Not sure 74 (68.5%) 2 (8.3%) 76 (57.6%)
   Yes 27 (25.0%) 22 (91.7%) 49 (37.1%)
Were these materials were utilized in our #GoodnightBloomberg campaign? Picture 3 < 0.0011
   N-Miss 13 3 16
   No 12 (11.3%) 8 (36.4%) 20 (15.6%)
   Not sure 92 (86.8%) 9 (40.9%) 101 (78.9%)
   Yes 2 (1.9%) 5 (22.7%) 7 (5.5%)
Were these materials were utilized in our #GoodnightBloomberg campaign? Picture 4 < 0.0011
   N-Miss 14 3 17
   No 11 (10.5%) 7 (31.8%) 18 (14.2%)
   Not sure 88 (83.8%) 10 (45.5%) 98 (77.2%)
   Yes 6 (5.7%) 5 (22.7%) 11 (8.7%)
Were these materials were utilized in our #GoodnightBloomberg campaign? Picture 5 < 0.0011
   N-Miss 13 2 15
   No 11 (10.4%) 3 (13.0%) 14 (10.9%)
   Not sure 90 (84.9%) 7 (30.4%) 97 (75.2%)
   Yes 5 (4.7%) 13 (56.5%) 18 (14.0%)
Were these materials were utilized in our #GoodnightBloomberg campaign? Picture 6 0.0301
   N-Miss 12 3 15
   No 13 (12.1%) 6 (27.3%) 19 (14.7%)
   Not sure 92 (86.0%) 14 (63.6%) 106 (82.2%)
   Yes 2 (1.9%) 2 (9.1%) 4 (3.1%)
Were these materials were utilized in our #GoodnightBloomberg campaign? Picture 7 < 0.0011
   N-Miss 13 2 15
   No 14 (13.2%) 3 (13.0%) 17 (13.2%)
   Not sure 90 (84.9%) 10 (43.5%) 100 (77.5%)
   Yes 2 (1.9%) 10 (43.5%) 12 (9.3%)
Were these materials were utilized in our #GoodnightBloomberg campaign? Picture 8 0.0011
   N-Miss 13 3 16
   No 13 (12.3%) 5 (22.7%) 18 (14.1%)
   Not sure 91 (85.8%) 13 (59.1%) 104 (81.2%)
   Yes 2 (1.9%) 4 (18.2%) 6 (4.7%)
Have you talked to anyone about the #GoodnightBloomberg campaign? < 0.0011
   No 117 (98.3%) 14 (56.0%) 131 (91.0%)
   Yes 2 (1.7%) 11 (44.0%) 13 (9.0%)
Do you know anyone who engaged in any way with the #GoodnightBloomberg campaign about promoting better sleep? < 0.0011
   No 115 (96.6%) 19 (76.0%) 134 (93.1%)
   Yes 4 (3.4%) 6 (24.0%) 10 (6.9%)
Did you engage in any way with the #GoodnightBloomberg campaign led by JHSPH students during the past 2 weeks? < 0.0011
   No 119 (100.0%) 0 (0.0%) 119 (82.6%)
   Yes 0 (0.0%) 25 (100.0%) 25 (17.4%)
In the last two weeks, how many days did you participate in the following techniques? Move 30 minutes total per day 0.2862
   Median (Q1, Q3) 9.00 (5.00, 12.00) 8.00 (4.00, 10.00) 9.00 (5.00, 12.00)
In the last two weeks, how many days did you participate in the following techniques? Use a breathing exercise 0.4192
   Median (Q1, Q3) 2.50 (1.00, 6.00) 3.00 (2.00, 6.00) 2.50 (1.00, 6.00)
In the last two weeks, how many days did you participate in the following techniques? Power down your screens (i.e. cell phone, tablet, computer, TV) 1 hour before bed 0.4192
   Median (Q1, Q3) 2.50 (1.00, 6.00) 3.00 (2.00, 6.00) 2.50 (1.00, 6.00)
Was the timing of the texts/posts convenient for you to adopt the recommended activity? 0.0401
   N-Miss 26 3 29
   No 48 (51.6%) 6 (27.3%) 54 (47.0%)
   Yes 45 (48.4%) 16 (72.7%) 61 (53.0%)
I think I would have had a more successful outcome (e.g. better sleep quality) if (choose all that may apply): 0.0471
   N-Miss 41 1 42
   I had more flexibility in my day 36 (46.2%) 6 (25.0%) 42 (41.2%)
   The campaign was longer 14 (17.9%) 10 (41.7%) 24 (23.5%)
   There was an in-person/on-campus component to the campaign 18 (23.1%) 7 (29.2%) 25 (24.5%)
   There were subject matter experts checking in with me one-on-one 10 (12.8%) 1 (4.2%) 11 (10.8%)
Please tell us how confident you feel practicing the following behaviors in order to get better sleep: I can maintain healthy sleep habits. 0.3611
   N-Miss 0 2 2
   Not at all confident 21 (17.6%) 5 (21.7%) 26 (18.3%)
   Somewhat confident 75 (63.0%) 11 (47.8%) 86 (60.6%)
   Extremely confident 23 (19.3%) 7 (30.4%) 30 (21.1%)
Please tell us how confident you feel practicing the following behaviors in order to get better sleep: I can cut out screen use 1 hour before bed. 0.4711
   N-Miss 0 2 2
   Not at all confident 56 (47.1%) 14 (60.9%) 70 (49.3%)
   Somewhat confident 47 (39.5%) 7 (30.4%) 54 (38.0%)
   Extremely confident 16 (13.4%) 2 (8.7%) 18 (12.7%)
Please tell us how confident you feel practicing the following behaviors in order to get better sleep: I can exercise for 30 minutes total each day. 0.3941
   N-Miss 0 2 2
   Not at all confident 14 (11.8%) 4 (17.4%) 18 (12.7%)
   Somewhat confident 54 (45.4%) 7 (30.4%) 61 (43.0%)
   Extremely confident 51 (42.9%) 12 (52.2%) 63 (44.4%)
Please tell us how confident you feel practicing the following behaviors in order to get better sleep: I can participate in a breathing exercise during the day or before bed. 0.8301
   N-Miss 1 1 2
   Not at all confident 15 (12.7%) 2 (8.3%) 17 (12.0%)
   Somewhat confident 62 (52.5%) 13 (54.2%) 75 (52.8%)
   Extremely confident 41 (34.7%) 9 (37.5%) 50 (35.2%)
Please rate your agreement with the following statements: Getting a good night’s sleep is important to me.
   N-Miss 0 2 2
   Strongly disagree 0 (0.0%) 0 (0.0%) 0 (0.0%)
   Somewhat disagree 1 (0.8%) 0 (0.0%) 1 (0.7%)
   Neither agree nor disagree 1 (0.8%) 0 (0.0%) 1 (0.7%)
   Somewhat agree 23 (19.3%) 2 (8.7%) 25 (17.6%)
   Strongly agree 94 (79.0%) 21 (91.3%) 115 (81.0%)
Please rate your agreement with the following statements: Having a regular sleep routine improves mental clarity/sharpness.
   N-Miss 1 1 2
   Strongly disagree 0 (0.0%) 0 (0.0%) 0 (0.0%)
   Somewhat disagree 1 (0.8%) 0 (0.0%) 1 (0.7%)
   Neither agree nor disagree 0 (0.0%) 0 (0.0%) 0 (0.0%)
   Somewhat agree 18 (15.3%) 5 (20.8%) 23 (16.2%)
   Strongly agree 99 (83.9%) 19 (79.2%) 118 (83.1%)
Please rate your agreement with the following statements: I feel positive about the quality of my sleep. 0.9451
   N-Miss 0 2 2
   Strongly disagree 9 (7.6%) 2 (8.7%) 11 (7.7%)
   Somewhat disagree 28 (23.5%) 5 (21.7%) 33 (23.2%)
   Neither agree nor disagree 20 (16.8%) 3 (13.0%) 23 (16.2%)
   Somewhat agree 42 (35.3%) 10 (43.5%) 52 (36.6%)
   Strongly agree 20 (16.8%) 3 (13.0%) 23 (16.2%)
Please rate your agreement with the following statements: I think cutting out screen use 1 hour before bed leads to better sleep. 0.8071
   N-Miss 0 1 1
   Strongly disagree 1 (0.8%) 0 (0.0%) 1 (0.7%)
   Somewhat disagree 5 (4.2%) 0 (0.0%) 5 (3.5%)
   Neither agree nor disagree 16 (13.4%) 3 (12.5%) 19 (13.3%)
   Somewhat agree 40 (33.6%) 10 (41.7%) 50 (35.0%)
   Strongly agree 57 (47.9%) 11 (45.8%) 68 (47.6%)
Please rate your agreement with the following statements: I think exercising regularly leads to better sleep.
   N-Miss 0 1 1
   Strongly disagree 0 (0.0%) 0 (0.0%) 0 (0.0%)
   Somewhat disagree 2 (1.7%) 0 (0.0%) 2 (1.4%)
   Neither agree nor disagree 4 (3.4%) 1 (4.2%) 5 (3.5%)
   Somewhat agree 32 (26.9%) 8 (33.3%) 40 (28.0%)
   Strongly agree 81 (68.1%) 15 (62.5%) 96 (67.1%)
Please rate your agreement with the following statements: I think participating in breathing exercises during the day or before bed leads to better sleep.
   N-Miss 0 1 1
   Strongly disagree 0 (0.0%) 0 (0.0%) 0 (0.0%)
   Somewhat disagree 3 (2.5%) 2 (8.3%) 5 (3.5%)
   Neither agree nor disagree 29 (24.4%) 7 (29.2%) 36 (25.2%)
   Somewhat agree 48 (40.3%) 9 (37.5%) 57 (39.9%)
   Strongly agree 39 (32.8%) 6 (25.0%) 45 (31.5%)
Please rate your agreement with the following statements: In the next two weeks, I will stop using screens 1 hour before bed for better sleep. 0.8791
   N-Miss 1 2 3
   Strongly disagree 22 (18.6%) 5 (21.7%) 27 (19.1%)
   Somewhat disagree 24 (20.3%) 3 (13.0%) 27 (19.1%)
   Neither agree nor disagree 24 (20.3%) 4 (17.4%) 28 (19.9%)
   Somewhat agree 34 (28.8%) 7 (30.4%) 41 (29.1%)
   Strongly agree 14 (11.9%) 4 (17.4%) 18 (12.8%)
Please rate your agreement with the following statements: In the next two weeks, I will exercise for at least 30 minutes total each day for better sleep. 0.3291
   N-Miss 0 2 2
   Strongly disagree 3 (2.5%) 0 (0.0%) 3 (2.1%)
   Somewhat disagree 5 (4.2%) 3 (13.0%) 8 (5.6%)
   Neither agree nor disagree 16 (13.4%) 1 (4.3%) 17 (12.0%)
   Somewhat agree 41 (34.5%) 8 (34.8%) 49 (34.5%)
   Strongly agree 54 (45.4%) 11 (47.8%) 65 (45.8%)
Please rate your agreement with the following statements: In the next two weeks, I will do a daily breathing exercise for better sleep. 0.9891
   N-Miss 0 2 2
   Strongly disagree 10 (8.4%) 2 (8.7%) 12 (8.5%)
   Somewhat disagree 17 (14.3%) 4 (17.4%) 21 (14.8%)
   Neither agree nor disagree 22 (18.5%) 4 (17.4%) 26 (18.3%)
   Somewhat agree 47 (39.5%) 8 (34.8%) 55 (38.7%)
   Strongly agree 23 (19.3%) 5 (21.7%) 28 (19.7%)
  1. Pearson’s Chi-squared test
  2. Kruskal-Wallis rank sum test
sleephygienepre <- readRDS(file="foranalysis.rds")

sleephygienepre <- sleephygienepre %>% 
  mutate(Q5_age = case_when(
    Q5_age >= 18 & Q5_age <= 25 ~ "18-25",
    Q5_age >= 26 & Q5_age <= 34 ~ "26-34",
    Q5_age >= 35 & Q5_age <= 44 ~ "35-44",
    Q5_age >= 45 & Q5_age <= 54 ~ "45-54",
    Q5_age >= 55 & Q5_age < 64 ~ "55-64",
    Q5_age >= 64 & Q5_age <= 75 ~ "64-75",
    Q5_age > 75 ~ "75+",
    is.na(Q5_age) ~ NA_character_
  )) %>% 
  mutate(Q5_age = factor(Q5_age)) %>%
  mutate(post = 0) %>% 
  mutate(
    Q10_hoursofsleeplast5workdays = Q10_workdayhoursofsleep,
    Q10_hoursofsleeppastweekend = Q11_weekendhoursofsleep,
    Q61_howoftensleepypasttwoweeks = Q9_howoftensleepy
  ) %>%
  select(post, Q3_role, Q2_program, Q4_gender, Q5_age, Q6_numberinhousehold, Q10_hoursofsleeplast5workdays, Q10_hoursofsleeppastweekend, Q61_howoftensleepypasttwoweeks) 
  
sleephygienepost <- sleephygiene %>% mutate(post = 1) %>% select(post, Q3_role, Q2_program, Q4_gender, Q5_age, Q6_numberinhousehold, Q10_hoursofsleeplast5workdays, Q10_hoursofsleeppastweekend, Q61_howoftensleepypasttwoweeks) 

sleephygienepreandpost <- rbind(sleephygienepre, sleephygienepost)

sleephygienepreandpost <- sleephygienepreandpost %>% mutate(Q61_smaller = case_when(
  is.na(Q61_howoftensleepypasttwoweeks) ~ NA_character_,
  Q61_howoftensleepypasttwoweeks == "Never" ~ "Never",
  Q61_howoftensleepypasttwoweeks == "Rarely" ~ "Rarely",
  Q61_howoftensleepypasttwoweeks == "Sometimes" ~ "Sometimes",
  Q61_howoftensleepypasttwoweeks == "Very often" | Q61_howoftensleepypasttwoweeks == "Always" ~ "Very often or Always",
)) %>%
  mutate(Q61_smaller = factor(Q61_smaller)) %>%
  mutate(Q2_program = case_when(
  Q2_program == "Post-doctoral student" ~ as.character("Post doctoral student"),
  TRUE ~ as.character(Q2_program)
  )) %>%
  mutate(Q2_program = factor(Q2_program))

tab1 <- tableby(post ~ Q3_role +
                  Q2_program + 
                  Q4_gender + 
                  Q5_age + 
                  Q6_numberinhousehold +
                  Q10_hoursofsleeplast5workdays +
                  Q10_hoursofsleeppastweekend +
                  Q61_smaller,
                data=sleephygienepreandpost, test=TRUE, total=TRUE, 
                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
summary(tab1, title='Table 1. Baseline information', pfootnote=TRUE, digits = 2)
Table 1. Baseline information
0 (N=209) 1 (N=149) Total (N=358) p value
Q3_role 0.0791
   N-Miss 3 4 7
   Faculty/Staff Member 6 (2.9%) 9 (6.2%) 15 (4.3%)
   Full-time student 140 (68.0%) 82 (56.6%) 222 (63.2%)
   Part-time student 60 (29.1%) 53 (36.6%) 113 (32.2%)
   Not affiliated with Bloomberg School of Public Health 0 (0.0%) 1 (0.7%) 1 (0.3%)
Q2_program 0.0091
   N-Miss 9 14 23
   Doctoral Student 54 (27.0%) 29 (21.5%) 83 (24.8%)
   Masters Student 140 (70.0%) 90 (66.7%) 230 (68.7%)
   Other 1 (0.5%) 6 (4.4%) 7 (2.1%)
   Post doctoral student 5 (2.5%) 10 (7.4%) 15 (4.5%)
Q4_gender 0.6171
   N-Miss 3 4 7
   Female 166 (80.6%) 121 (83.4%) 287 (81.8%)
   Male 35 (17.0%) 23 (15.9%) 58 (16.5%)
   Non-binary / third gender 4 (1.9%) 1 (0.7%) 5 (1.4%)
   Prefer not to say 1 (0.5%) 0 (0.0%) 1 (0.3%)
Q5_age 0.5461
   N-Miss 5 4 9
   18-25 64 (31.4%) 44 (30.3%) 108 (30.9%)
   26-34 98 (48.0%) 63 (43.4%) 161 (46.1%)
   35-44 32 (15.7%) 24 (16.6%) 56 (16.0%)
   45-54 9 (4.4%) 12 (8.3%) 21 (6.0%)
   55-64 1 (0.5%) 1 (0.7%) 2 (0.6%)
   64-75 0 (0.0%) 1 (0.7%) 1 (0.3%)
How many people live in your household, including yourself? 0.1462
   Median (Q1, Q3) 2.00 (2.00, 3.00) 2.00 (2.00, 3.00) 2.00 (2.00, 3.00)
During the past 5 workdays, how many hours of sleep did you get per night on average? 0.7312
   Median (Q1, Q3) 7.00 (6.00, 7.50) 7.00 (6.00, 7.00) 7.00 (6.00, 7.50)
During the past weekend, how many hours of sleep did you get per night on average? 0.1872
   Median (Q1, Q3) 8.00 (7.00, 9.00) 8.00 (7.00, 8.00) 8.00 (7.00, 9.00)
Q61_smaller 0.0981
   N-Miss 69 54 123
   Never 3 (2.1%) 2 (2.1%) 5 (2.1%)
   Rarely 27 (19.3%) 23 (24.2%) 50 (21.3%)
   Sometimes 99 (70.7%) 54 (56.8%) 153 (65.1%)
   Very often or Always 11 (7.9%) 16 (16.8%) 27 (11.5%)
  1. Pearson’s Chi-squared test
  2. Kruskal-Wallis rank sum test
library(sjPlot)
sleephygiene <- sleephygiene %>% mutate(Q69_didyouengagewiththecampaignbinary = case_when(
  Q69_didyouengagewiththecampaign == "No" ~ 0,
  Q69_didyouengagewiththecampaign == "Yes" ~ 1)) %>%
  mutate(Q4_gender_binary = case_when(
    Q4_gender == "Male" ~ 1,
    Q4_gender == "Female" ~ 0,
    TRUE ~ NA_real_
  )) %>%
  mutate(Q4_gender_binary = factor(Q4_gender_binary, labels = c("Female", "Male"))) %>%
  mutate(happywithsleepqualitycombined = case_when(
    Q90_areyouhappywithyoursleepquality_awareofcampaign == "Yes" ~ 1,
    Q90_areyouhappywithyoursleepquality_awareofcampaign == "No" ~ 0,
    Q91_areyouhappywithyoursleepquality_notawareofcampaign == "Yes" ~ 1,
    Q91_areyouhappywithyoursleepquality_notawareofcampaign == "No" ~ 0,
    Q89_ratesleepquality_notawareofcampaign == "Good" ~ 1,
    Q89_ratesleepquality_notawareofcampaign == "Excellent" ~ 1,
    Q89_ratesleepquality_notawareofcampaign == "Poor" ~ 0,
    Q89_ratesleepquality_notawareofcampaign == "Fair" ~ 0,
  )) %>%
  mutate(happywithsleepqualitycombined = factor(happywithsleepqualitycombined)) %>%
  mutate(Q67_1 = case_when(
    is.na(Q67_1) ~ 0,
    TRUE ~ as.numeric(Q67_1)
  )) %>%
  mutate(Q67_2 = case_when(
    is.na(Q67_2) ~ 0,
    TRUE ~ as.numeric(Q67_2)
  )) %>%
  mutate(Q67_3 = case_when(
    is.na(Q67_3) ~ 0,
    TRUE ~ as.numeric(Q67_3)
  )) %>%
  mutate(pointscombinedperdays = Q67_1 + Q67_2 + Q67_3) %>%
  mutate(ratesleepqualitycombined = case_when(
    Q89_ratesleepquality_notawareofcampaign == "Good" ~ 1,
    Q89_ratesleepquality_notawareofcampaign == "Excellent" ~ 1,
    Q89_ratesleepquality_notawareofcampaign == "Poor" ~ 0,
    Q89_ratesleepquality_notawareofcampaign == "Fair" ~ 0,
  ))

#Participating in the campaign
mylogit <- glm(Q69_didyouengagewiththecampaignbinary ~ Q4_gender_binary + Q10_hoursofsleeplast5workdays + Q10_hoursofsleeppastweekend, family = binomial(link = "logit"), data = sleephygiene)
tab_model(mylogit)
  Q69_didyouengagewiththecampaignbinary
Predictors Odds Ratios CI p
(Intercept) 0.04 0.00 – 1.15 0.069
Q4_gender_binary: Male 0.53 0.08 – 2.08 0.427
On average, how many
hours of sleep did you
get per night during the
following periods of
time: during the last 5
workdays?
0.86 0.55 – 1.37 0.507
On average, how many
hours of sleep did you
get per night during the
following periods of
time: during the past
weekend?
1.40 0.93 – 2.14 0.115
Observations 141
R2 Tjur 0.024
#Happy with sleep quality
mylogit <- glm(happywithsleepqualitycombined ~ Q4_gender_binary + Q10_hoursofsleeplast5workdays + Q10_hoursofsleeppastweekend + Q69_didyouengagewiththecampaignbinary, family = binomial(link = "logit"), data = sleephygiene)
tab_model(mylogit)
  happywithsleepqualitycombined
Predictors Odds Ratios CI p
(Intercept) 0.00 0.00 – 0.01 <0.001
Q4_gender_binary: Male 1.54 0.55 – 4.42 0.416
On average, how many
hours of sleep did you
get per night during the
following periods of
time: during the last 5
workdays?
2.82 1.78 – 4.79 <0.001
On average, how many
hours of sleep did you
get per night during the
following periods of
time: during the past
weekend?
1.05 0.73 – 1.51 0.783
Q69_didyouengagewiththecampaignbinary 1.47 0.51 – 4.26 0.472
Observations 141
R2 Tjur 0.209
mylogit <- glm(happywithsleepqualitycombined ~ Q10_hoursofsleeppastweekend + Q4_gender_binary + pointscombinedperdays, family = binomial(link = "logit"), data = sleephygiene)
tab_model(mylogit)
  happywithsleepqualitycombined
Predictors Odds Ratios CI p
(Intercept) 0.01 0.00 – 0.10 <0.001
On average, how many
hours of sleep did you
get per night during the
following periods of
time: during the past
weekend?
1.64 1.23 – 2.25 0.001
Q4_gender_binary: Male 1.58 0.59 – 4.34 0.367
pointscombinedperdays 1.06 1.01 – 1.12 0.018
Observations 141
R2 Tjur 0.108